package com.letfox.ad.controller.ad;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.letfox.ad.controller.BaseController;
import com.letfox.ad.model.ADAppProduct;
import com.letfox.ad.service.AdAppServService;
import com.letfox.common.enums.ResponseEnum;
import com.letfox.common.model.ResultResponse;

@Controller
@RequestMapping(value = "/ad_app_serv")
public class ADAppServController extends BaseController{
	
	@Autowired
	private AdAppServService adAppServService;
	
	@RequestMapping(value = "/create", method = RequestMethod.POST)
	@ResponseBody
	public ResultResponse adAppCreate(ADAppProduct  adAppProduct) {
		try {
			resultResponse=adAppServService.adAppCreate(adAppProduct);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			resultResponse.setStatusCode(ResponseEnum.R500.getCode());
			resultResponse.setStatusMessage(ResponseEnum.R500.getMessage());
		}
		return resultResponse;
	}
	
	@RequestMapping(value = "/total_census", method = RequestMethod.POST)
	@ResponseBody
	public ResultResponse adTotalCensus(String request_json){
		try {
			resultResponse=adAppServService.adTotalCensus(request_json);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			e.printStackTrace();
			resultResponse.setData("system erro");
			resultResponse.setStatusCode(ResponseEnum.R500.getCode());
			resultResponse.setStatusMessage(ResponseEnum.R500.getMessage());
		}
		return resultResponse;
	}
	
	@RequestMapping(value = "/censuslist", method = RequestMethod.POST)
	@ResponseBody
	public ResultResponse adCensusList(String request_json){
		try {
			resultResponse=adAppServService.adCensusList(request_json);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			e.printStackTrace();
			resultResponse.setData("system erro");
			resultResponse.setStatusCode(ResponseEnum.R500.getCode());
			resultResponse.setStatusMessage(ResponseEnum.R500.getMessage());
		}
		return resultResponse;
	}
	 
}
